Repository navigation
feat(filters): choose case sensitivity for PostgreSQL text filters - #1252
Conversation
Add a Match case toggle to contains / starts with / ends with filters on PostgreSQL-dialect connections. Unticking it generates ILIKE instead of LIKE; the default stays LIKE and other dialects are unchanged. Closes TabularisDB#1164
| <input | ||
| type="checkbox" | ||
| checked={matchCase} | ||
| onChange={(e) => onChange({...filter, matchCase: e.target.checked})} |
There was a problem hiding this comment.
WARNING: Toggling "Match case" does not reset the filter's applied state
TableToolbar.handleFilterChange (src/components/ui/TableToolbar.tsx, ~line 316) decides whether to call onResetApplied by comparing only column, operator, value and value2. Since matchCase is not part of that comparison, flipping this checkbox is treated as an "only enabled changed" update: the row keeps its "applied" indicator even though the clause it would generate has changed (LIKE <-> ILIKE) and the displayed data no longer matches the filter. Add prev.matchCase === updated.matchCase to the onlyEnabledChanged check, and cover it with a test.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The previously reported issue is resolved: Files Reviewed (18 files)
Previous Review Summary (commit 0cea48c)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 0cea48c)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (16 files)
Reviewed by claude-sonnet-5.5 · Input: 248 · Output: 1.2K · Cached: 184.1K Review guidance: REVIEW.md from base branch |
Toggling Match case changes the generated clause, so the row's Applied feedback must be cleared like it is for a column, operator or value change.
|
Good catch, thanks. Toggling Match case changed the clause but not the row's Applied state. Fixed in c4a2fce: the comparison in |
debba
left a comment
There was a problem hiding this comment.
Thanks for picking this up! What I like most is that ILIKE is gated twice, in the UI and again in buildLiteralLikeClause. A stale matchCase: false can never leak ILIKE onto MySQL, SQLite or other dialects, and there's a test for both built-in ids and plugin capability objects. Resetting the row's Applied state when the box is toggled is a good fix too.
I'm requesting changes only because GitHub can't merge it: #676 moved the frontend to packages/web-ui/src. Locally, git follows the renames and the merge goes through cleanly, and the filter, toolbar and i18n tests pass on the merged tree. So a plain rebase on main should do it.
A few nits for while you're there, or later:
MATCH_CASE_OPSinFilterRowduplicatesLikeMatchModefromfilterBar.ts. A smallisLikeMatchMode()helper would keep the list in one place.- The checkbox uses
focus-visible:ring-2 focus-visible:ring-focus/60..rules/accessibility.mdasks forfocus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus. - Some labels are a bit terse for a checkbox. In Italian, "Distingui maiuscole/minuscole" reads more naturally than "Maiuscole/minuscole", and in German "Groß-/Kleinschreibung beachten" works better than the bare noun.
debba
left a comment
There was a problem hiding this comment.
I merged main into your branch, since the only thing holding it back was the move to packages/web-ui and git handled the renames cleanly, and then tried it in the app. On a Postgres table with Ada / ADA / ada / Adalbert / 100%_off / x_y, contains "ada" with Match case returns only ada. Unticking it flips the row back to Apply, the query switches to ILIKE, and all four Ada rows come back. %_ and _ are still matched literally. Starts with and ends with follow the box too, and it disappears for =, LIKE and IN. On MySQL the box never shows and the filter stays LIKE. Tests are green, so I'm merging it. Thanks again! The nits from my earlier review can go in a follow-up whenever you like.
Summary
Literal text filters (contains / starts with / ends with) always generated
LIKE, so a case-insensitive match was not possible from the structured filter UI. On PostgreSQL-dialect connections the filter row now has a "Match case" toggle: ticked (the default) keepsLIKE, unticked generatesILIKE.Changes
src/utils/filterBar.ts:StructuredFiltergets an optionalmatchCase(undefined ortrue=LIKE,false=ILIKE).buildLiteralLikeClausetakes an optional{matchCase}; the%,_, quote and escape-character handling is shared, so escaping is identical in both modes. NewsupportsMatchCaseToggle(driver), which reusesisPostgresDialect.src/components/ui/FilterRow.tsx: a "Match case" checkbox next to the value field, shown only whensupportsMatchCaseis set and the operator is contains / starts with / ends with. It is a native checkbox inside a<label>, so it is keyboard accessible and has a visible focus ring.src/components/ui/TableToolbar.tsx: passessupportsMatchCaseToggle(quotingDriver)to each row.src/i18n/locales/*.json:toolbar.matchCaseandtoolbar.matchCaseHintin all 11 locales.Plugin drivers
The decision is capability-based, not driver-id based: the toggle shows (and
ILIKEis generated) for the built-in PostgreSQL driver and for any plugin whosesql_dialectispostgres, including an omittedsql_dialect, which defaults topostgreslikeisPostgresDialectelsewhere. MySQL, SQLite, MSSQL and other dialects get no toggle, andILIKEis never generated for them even if amatchCase: falseflag is somehow present, so their filters are unchanged. The rawLIKE/NOT LIKEoperators are untouched.buildLiteralLikeClausehas a second caller, "filter by cell value", which does not pass the option and keepsLIKE.Tests
tests/utils/filterBar.test.ts: default and match-case-on keepLIKE; match-case-off givesILIKEfor all three operators on built-in PostgreSQL and on a plugin declaringsql_dialect: "postgres"; escaping of%,_,'and!is the same in both modes; MySQL/SQLite/MSSQL and plugins declaring them never getILIKE; rawLIKEis untouched; per-filter behaviour throughbuildStructuredFilterClause;supportsMatchCaseToggle.tests/components/ui/FilterRow.test.tsx: the toggle is hidden without support and for other operators, shown and checked by default, storesmatchCase: falsewhen unticked, and reflects an unticked filter.ILIKEassertions cannot pass without the change. I did not run the suite against the old code.ILIKE ... ESCAPE '!'is standard PostgreSQL syntax. The new translations (other than English) are mine and could use a native check.Closes #1164